package com.ruoyi.energy.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.energy.mapper.TcCarInOutMapper;
import com.ruoyi.energy.domain.TcCarInOut;
import com.ruoyi.energy.service.ITcCarInOutService;

/**
 * 车辆出入Service业务层处理
 *
 * @author cjie
 * @date 2021-07-29
 */
@Service
public class TcCarInOutServiceImpl implements ITcCarInOutService {
    @Autowired
    private TcCarInOutMapper tcCarInOutMapper;

    /**
     * 查询车辆出入
     *
     * @param id 车辆出入ID
     * @return 车辆出入
     */
    @Override
    public TcCarInOut selectTcCarInOutById(String id) {
        return tcCarInOutMapper.selectTcCarInOutById(id);
    }

    /**
     * 查询车辆出入列表
     *
     * @param tcCarInOut 车辆出入
     * @return 车辆出入
     */
    @Override
    public List<TcCarInOut> selectTcCarInOutList(TcCarInOut tcCarInOut) {
        return tcCarInOutMapper.selectTcCarInOutList(tcCarInOut);
    }

    /**
     * 新增车辆出入
     *
     * @param tcCarInOut 车辆出入
     * @return 结果
     */
    @Override
    public int insertTcCarInOut(TcCarInOut tcCarInOut) {
        tcCarInOut.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        tcCarInOut.setCreateTime(DateUtils.getNowDate());
        tcCarInOut.setCreateBy(SecurityUtils.getUsername());
        return tcCarInOutMapper.insertTcCarInOut(tcCarInOut);
    }

    /**
     * 修改车辆出入
     *
     * @param tcCarInOut 车辆出入
     * @return 结果
     */
    @Override
    public int updateTcCarInOut(TcCarInOut tcCarInOut) {
        tcCarInOut.setUpdateTime(DateUtils.getNowDate());
        tcCarInOut.setUpdateBy(SecurityUtils.getUsername());
        return tcCarInOutMapper.updateTcCarInOut(tcCarInOut);
    }

    /**
     * 批量删除车辆出入
     *
     * @param ids 需要删除的车辆出入ID
     * @return 结果
     */
    @Override
    public int deleteTcCarInOutByIds(String[] ids) {
        return tcCarInOutMapper.deleteTcCarInOutByIds(ids);
    }

    /**
     * 删除车辆出入信息
     *
     * @param id 车辆出入ID
     * @return 结果
     */
    @Override
    public int deleteTcCarInOutById(String id) {
        return tcCarInOutMapper.deleteTcCarInOutById(id);
    }
}
